import hyRequest from "@/service/index"
import { IAccount, ILoginResult } from "./type"
import { IDataType } from "../type"
import localCache from "@/utils/cache"
enum LoginAPI {
  AccountLogin = "/LoginExt",
  LoginUserInfo = "/Profile",
  UserMenus = "/role/"
}
// 登录接口
export function accountLoginRequest(account: IAccount) {
  return hyRequest.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: {
      ...account,
      app_key: "421024995A3BEB6C46B9AF57B42AC5CB",
      username: account.name
    }
  })
}
// 用户信息接口
export function requestUserInfoById(uuid: string) {
  return hyRequest.post<IDataType>({
    url: LoginAPI.LoginUserInfo,
    data: {
      app_key: "421024995A3BEB6C46B9AF57B42AC5CB",
      uuid,
      token: localCache.getCache("token"),
      showLoading: false
    }
  })
}
// 用户菜单接口
export function requestUserMenusByRoleId(uuid: string) {
  return hyRequest.get<IDataType>({
    url: LoginAPI.UserMenus + uuid + "/menu",
    showLoading: false
  })
}
